package com.da.javatest.leetCode;

/**
 * @author chenlida
 * @date 2019/1/14 18:35
 * @description
 */
public class Code509 {
    public int fib(int N) {
        if (N == 0) {
            return 0;
        }
        if (N == 1) {
            return 1;
        }
        int total = 0;
        int pre1 = 1;
        int pre2 = 0;
        for (int i = 2; i <= N; i++) {
            total = pre1 + pre2;
            pre2 = pre1;
            pre1 = total;
        }

        return total;
    }
}
